<?php
/**
 * Created by PhpStorm.
 * User: JimmyZhang
 * Date: 2017/1/13
 * Time: 21:12
 */

/**
 * 店铺粉丝
 */
function storeAttention($local_id){
    return M('b2c_member_like_store')->where(['local_id' => $local_id])->count();
}

/*
 * 购物车标记数量
 */
function userCartNum(){
    $CartNum =  M('b2c_carts')->where(['member_id'=>session('userInfo')['member_id']])->field('SUM(cart_num) as num')->find()['num'];

    if(empty($CartNum)){
        $CartNum = 0;
    }
    return $CartNum;
}

/**
 * 获取链接
 * @return string
 */
function get_url() {
    $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
    $relate_url['top'] = $sys_protocal;
    $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '';
    $relate_url['parameter'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : $path_info);
    $relate_url['host'] = $_SERVER['HTTP_HOST'];
    return $relate_url;
    //return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url;
}

